<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <link href="../CSS/Search.css" rel="stylesheet" type="text/css"/>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Trần Quang Kha</title>
    </head>
    <body>
        <div id="Pages">
            <div id="User">
                <div class="login">
                    <input type="submit" name="Submit" value="Register">
                    <input type="submit" name="Submit" value="Login">
                    <a>Remember me</a><input type="checkbox" name="vehicle" value="Bike">
                    <input type="password" name="passwords" value=""><a>Password:</a>
                    <input type="text" name="Username" value=""><a>Username:</a>


                </div>
            </div>
            <div id="Banner">
                <img src="../Image/Banner.jpg">
            </div>
            <!-- Menu -->
            <div id="Menu">
                <ul>
                    <li><a href="#"><b>HOME</b></a></li>
                    <li><a href="#"><b>FORUMS</b></a></li>
                    <li><a href="#"><b>CONTENT</b></a></li>
                    <li><a href="#"><b>CONTACT</b></a></li>
                </ul>
                <div id="Search">
                    <input type="text" name="search" value="">
                    <input type="submit" name="Submit" value="Search">
                </div>
            </div>
            <!--End Menu -->
            <div id="content">
                <div id="noidung">
                    <?php
                    require_once '../model/db.php';
                    require_once '../model/keywords.php';
                    require_once '../model/works.php';
                    require_once '../Class/Pagination.php';
                    ?>

                    <?php
                    $page = 1;
                    $keywords = new work();
                    $link = "search.php";
                    $per_page = PER_PAGE;      
                    if (isset($_GET['page']))
                    $page=$_GET['page'];
                    $list = $keywords->works1();
                    $total = mysql_num_rows(mysql_query("SELECT * FROM works ")); //đếm số dòng
                    $from = $per_page * ($page - 1);
                    $to=PER_PAGE;
                    $query = "SELECT * FROM works LIMIT $from ,$to";
                    $list = $keywords->select($query);
                    
                    ?>
                    <form method="GET">
                        <table border="1px">
                            <tr>
                                <td>ID</td>
                                <td>Name</td>
                                <td>Images</td>
                                <td>Khu Vực </td>
                                <td>Options</td>
                            </tr>
                            <?php foreach ($list as $lists) : ?> 
                                <tr>
                                    <td><a><?php echo $lists['id']; ?></a></td>           
                                    <td><a href='<?php echo $lists['url']; ?>'><?php echo $lists['name']; ?></a></td>
                                    <td><?php echo $lists['image']; ?></td>
                                    <td><a><?php echo $lists['location']; ?></a></td>
                                    <td>
                                        <ul>
                                            <li><a href="edit.php?edit=<?php echo $lists['id'] ?>">Edit</a></li>
                                            <li><a href="Edits.php?edits=<?php echo $lists['id']?>">Edits</a></li>
                                        </ul>
                                    </td>  
                                </tr>
                            <?php endforeach; ?>
                        </table>
                        <?php
                        if (!isset($_GET['page'])) {
                            for ($i = 1; $i <= 10; $i++) {
                                ?>
                                <a href='search.php?page=<?php echo $i ?>'><?php echo $i ?></a>
                            <?php } ?>
                            <a href='search.php?page=2'> [Trang sau] </a>
                            <?php if (isset($_GET['page'])) { ?>
                                <a href='search.php?page=<?php echo $_GET['page'] + 1 ?>'> Next </a>
                                <?php
                            }
                        } else {
                            $pagi = new Pagination();
                            $show = $pagi->paging($total, $per_page, $link);
                        }
                        ?>
                    </form>
                </div>
            </div>

        </div>
        <div id="Footer"></div>
    </body>
</html>
<?php



